<?php
//Start session
session_start();

//Include database connection details
require_once('../../inc/config.inc');

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}
$submit=$_POST['submit'];
$name=$_POST['a_name'];
$price=$_POST['a_price'];
$duration=$_POST['a_duration'];

//insert new record in appointment_type table
if(isset($submit)){
	$query=mysql_query("INSERT INTO appointment_types VALUES(null,'$name','$price','$duration','".$_SESSION['USER_ID']."')");
	if($query){
		header("location: ../appointment-types.php?add=success");
	}
	else{
		echo mysql_error();
	}
}